<?php session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

<html>

<head>
<title>Parent Informer RCSHS - Account Request Attempt</title>

<link rel=stylesheet href="../../../css-layouts/themes/defaulttheme.css" type="text/css">
<link rel=stylesheet href="../../../css-layouts/headlinks.css" type="text/css">

<script type="text/javascript">
<!--
 var RecaptchaOptions = {
  theme : 'custom',
  custom_theme_widget: 'catcharea'
 };
//-->
</script>

</head>

<?php 

 /*
  * Use the ever-useful reCAPTCHA. The public
  * key here is for the domain http://localhost.
  */
 require_once("../../lib/recaptchalib.php");
 require_once("../../../sqlconfig.php");
 $catchpubkey = "6Leo8MMSAAAAANgHo9cksNq4o-O8nSGSHhp96XDz";

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error());
 mysql_select_db($mydb) or die(mysql_error()); 

 /*
  * This condition checks whether there were existing
  * cookies in the user's computer. If there is, the user
  * is redirected to the main page. If not, then the user
  * is redirected to the main login page.
  */
 if(isset($_COOKIE["parentinformerprcshs"]) && isset($_COOKIE["parentinformerurcshs"])) { 
  $username = $_COOKIE["parentinformerprcshs"]; 
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    header("Location: ../../logerr_atmpt.php");
   }
   else {
    header("Location: ../../../");
   }
  }
 }
 else {

?>

<body>

<div id="mainhead"><br><br><br></div>
<br>
<br>

<div class="notifymain">

<?php

   /*
    * Display the appropriate notice.
    *
    * Error codes (For use in $_SESSION['penderr'];)
    *
    * CODE 1: No input in one or more fields
    * CODE 2: E-mail address does not match the preset format.
    * CODE 3: Passwords does not match
    * CODE 4: Desired username was already requested by another
    *         user
    * CODE 5: Desired username already exists in the database
    */
   $theerror = $_SESSION['penderr'];
   switch($theerror) {
    case 1:
     echo "<b>Incomplete Input</b><br>";
     echo "You did not input a value on one or more of the fields in the previous page.<br>";
     echo "Please try again.<br>";
     break;
    case 2:
     echo "<b>Invalid E-mail Address</b><br>";
     echo "The e-mail address you have typed in the previous page is of invalid format.<br>";
     echo "Please type in a valid e-mail address.<br>";
     break;
    case 3:
     echo "<b>Password Mismatch</b><br>";
     echo "The passwords you have typed in the previous page does not match.<br>";
     echo "Please type your password twice.<br>";
     break;
    case 4:
     echo "<b>Username Requested</b><br>";
     echo "Your desired username was already requested by another user.<br>";
     echo "Please choose another username.<br>";
     break;
    case 5:
     echo "<b>Username Exists</b><br>";
     echo "Your desired username already exists in our database.<br>";
     echo "Please choose another username.<br>";
     break;
    case 6:
     echo "<b>Incorrect CAPTCHA</b><br>";
     echo "The answer to the CAPTCHA was incorrect.<br>";
     echo "Please answer it correctly.<br>";
     break;
    default:
     echo "";
    }

?>

</div>

<br><br><br><br><br>

<br>
<center><span id="heading">Request for Account</span></center>
<br>

<form method=post action="procacct.php">
<table align=center id="labelforms">

<tr>
<td>Username:</td>
<td><input type="text" name="desusrnm" size=29 value=""></td>
</tr>

<tr>
<td>Password:</td>
<td><input type="password" name="despaswrd" size=29></td>
</tr>

<tr>
<td>Confirm Password:</td>
<td><input type="password" name="confpaswrd" size=29></td>
</tr>

<tr>
<td>Status:</td>
<td>
<select name="despriv">
<option value=0 selected>Please select a privilege...</option>
<option value=1>ADMINISTRATOR/ADVISER</option>
<option value=2>SUBJECT TEACHER</option>
<option value=3>STUDENT</option>
</select>
</td>
</tr>

<tr>
<td>E-mail Address:</td>
<td><input type="text" name="mymail" size=29 value=""></td>
</tr>

<tr>
<td>Reason for Request:</td>
<td><textarea rows=5 cols=30 wrap="physical" name="comnt" value=""></textarea></td>
<tr>

<tr>
<td></td>

<td colspan=2>

<!--
  This is the start of the reCAPTCHA custom theme code.
  -->
<div id="catcharea" style="display:none">
 <div id="recaptcha_image"></div>
 <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect input. Please try again.</div>
 <span class="recaptcha_only_if_image">Input the words shown above separated by a space:</span>
 <span class="recaptcha_only_if_audio">Input the numbers you hear:</span>
 <br>
 <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
 <br>
 <a href="javascript:Recaptcha.reload()">RELOAD</a> || 
 <span class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">AUDIO</a></span>
 <span class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">IMAGE</a></span> ||
 <a href="javascript:Recaptcha.showhelp()">HELP</a>
</div>

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=<?php echo $catchpubkey; ?>">
</script>

<noscript>
 <iframe src="http://www.google.com/recaptcha/api/noscript?k=<?php echo $catchpubkey; ?>" height="300" width="500" frameborder="0">
 </iframe>
 <br>
 <textarea name="recaptcha_challenge_field" rows="3" cols="40">
 </textarea>
 <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
<!--
  End of reCAPTCHA custom theme code.
  -->

</td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="submitbtn" value="Request Account"></td>
</tr>

</table>
</form>

<div class="footnav" align=center>

<hr>

<a href="../../../">Main Page</a> ||
<b>Request Account</b> ||
<a href="#">Help</a> ||
<a href="#">Disclaimer</a> ||
<a href="../../../externalaffairs/links.php">Links</a> ||
<a href="#">About</a>
<br>

<span id="copyme">
&copy; 2011 Roosevelt College Science High School. All rights reserved.
</span>

</div>

</body>

<?php

 }

?>

</html>